import Vue from "vue";
import VueRouter from "vue-router";
import BasicLayout from "@/layouts/BasicLayout.vue";
import PageView from "@/layouts/PageView.vue";

Vue.use(VueRouter);

// 路由配置
const RouterConfig = {
  // mode: 'history',
  routes: [
    {
      path: "/",
      component: BasicLayout, //() => import('@/views/home.vue'),
      meta: {
        title: "Home",
      },
      redirect: "/home",
      children: [
        {
          path: "/home",
          name: "Home",
          component: () => import("@/views/home.vue"),
          meta: {
            title: "Home",
          },
        },
        {
          path: "/C_Saving",
          name: "C_Saving",
          component: () => import("@/views/C_Saving.vue"),
          meta: {
            title: "C_Saving",
          },
        },
        {
          path: "/DeliveryContract",
          name: "DeliveryContract",
          component: () => import("@/views/DeliveryContract.vue"),
          meta: {
            title: "DeliveryContract",
          },
        },
        {
          path: "/CurrencyAccount",
          name: "CurrencyAccount",
          component: () => import("@/views/CurrencyAccount.vue"),
          meta: {
            title: "CurrencyAccount",
          },
        },
        {
          path: "/recharge",
          name: 'recharge',
          component: () => import("@/views/recharge.vue"),
          meta: {
            title: "recharge",
          },
        },
        {
          path: "/rechargeOpen",
          name: 'rechargeOpen',
          component: () => import("@/views/rechargeOpen.vue"),
          meta: {
            title: "recharge",
          },
        },
        {
          path: "/withdrawOpen",
          name: 'withdrawOpen',
          component: () => import("@/views/withdrawOpen.vue"),
          meta: {
            title: "withdrawOpen",
          },
        },
        {
          path: "/PerpetualContract",
          name: 'PerpetualContract',
          component: () => import("@/views/PerpetualContract.vue"),
          meta: {
            title: "PerpetualContract",
          },
        },
        {
          path: "/bigTrade",
          name: 'bigTrade',
          component: () => import("@/views/bigTrade.vue"),
          meta: {
            title: "bigTrade",
          },
        },
        {
          path: '/staking',
          meta: {
            title: "staking",
          },
          component: PageView,
          children: [
            {
              path: "/stakingOrder",
              name: "StakingOrder",
              component: () => import("@/views/stakingOrder.vue"),
            },
            {
              path: "/stakingDetail",
              name: 'stakingDetail',
              component: () => import("@/views/stakingDetails.vue"),
              meta: {
                title: "StakingDetail",
              },
            }
          ]
        },
        {
          path: '/user',
          meta: {
            title: 'User'
          },
          component: PageView,
          children: [
            {
              path: '/authentication',
              name: 'Authentication',
              component: () => import("@/views/user/authentication.vue")
            }
          ]
        },
        {
          path: '/currencyTransaction',
          name: 'CurrencyTransaction',
          meta: {
            title: 'CurrencyTransaction'
          },
          component: () => import("@/views/currencyTransaction.vue")
        }
      ],
    },
    {
      path: "/login",
      name: "Login",
      component: () => import("@/views/user/login.vue"),
      meta: {
        title: "Login",
      },
    },
    {
      path: "/register",
      component: () => import("@/views/user/register.vue"),
      meta: {
        title: "Register",
      },
    },
    {
      path: "/forgetPassword",
      component: () => import("@/views/user/forgetPassword.vue"),
      meta: {
        title: "ForgetPassword",
      },
    },
    {
      path: "/privacy",
      component: () => import("@/views/user/privacy.vue"),
      meta: {
        title: "Privacy",
      },
    },
  ],
};

const router = new VueRouter(RouterConfig);
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};

console.log(router, 'router')
export default router;
